<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:beans="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mongo="http://www.springframework.org/schema/data/mongo"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
	
	<!-- Enables the Spring MVC @Controller programming model -->
	<annotation-driven />

	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
	<resources mapping="/resources/**" location="/resources/" />

	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<beans:property name="prefix" value="/WEB-INF/views/" />
		<beans:property name="suffix" value=".jsp" />
	</beans:bean>
	
	 <!-- EntityManagerFactory -->
  <beans:bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
    <beans:property name="persistenceUnitName" value="persistenceUnit"/>
    <beans:property name="dataSource" ref="dataSource"/>
    <!-- <beans:property name="persistenceUnitManager">
    	<beans:bean class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager" > 
    		<beans:property name="dataSource" ref="dataSource"/>
    	</beans:bean>
    </beans:property> -->
  </beans:bean> 
	
  <!-- MySQL Datasource with Commons DBCP connection pooling -->		
  <beans:bean class="org.apache.commons.dbcp.BasicDataSource" id="dataSource">
    <beans:property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <beans:property name="url" value="jdbc:mysql://localhost:3306/taskDB"/>
    <beans:property name="username" value="root"/>
    <beans:property name="password" value="root"/>
  </beans:bean>	
  
  <!-- Transaction Manager -->
  <beans:bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
    <beans:property name="entityManagerFactory" ref="entityManagerFactory"/>
  </beans:bean>
   
   
  <!-- Enable @Transactional annotation -->
  <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/> 
	
	
  <context:component-scan base-package="com.ericsson.eritask" />
	<beans:bean id="multipartResolver"
		class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
	<!-- mongo -->
	<mongo:mongo host="localhost" port="27017"></mongo:mongo>
	<mongo:db-factory host="localhost" port="27017" id="mongoDbFactory" dbname="ssdb" />	
	<mongo:mapping-converter  id="converter"  db-factory-ref="mongoDbFactory" />
	<beans:bean name="gridFsTemplate"
		class="org.springframework.data.mongodb.gridfs.GridFsTemplate">
		<beans:constructor-arg ref="mongoDbFactory" />
		<beans:constructor-arg ref="converter" />
	</beans:bean>

	<beans:bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
		<beans:constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
	</beans:bean>
	
	
	
</beans:beans>
